[release/7.0] Fix to #29279 - EF7 - GroupBy on Json column property + First/FirstOrDefault generates incorrect SQL #29288
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem was that in VisitChildren for JsonQueryExpression we were not passing key columns stored in _keyPropertyMap thru the visitor, so the aliases got out of sync. Fix is to process these key columns also and then update the JsonQueryExpression with new map if any of the columns have been modified by the visitor.
Fixes #29279
Customer impact
Exception in a relatively simple GroupBy + paging scenario involving new JSON mapping feature.
How found
Found by a customer testing EF7 bits.
Regression
No, this is in the new feature.
Testing
New testing added for the reported scenario and additional cases around it.
Risk
Low, only affects JSON scenarios (code change is in the new class that only gets created to traverse JSON expressions). It should be safe to pass key columns through the visitor - we already do that for the JSON column. Could be unnecessary work, but safe.